Skip to main content

pmod

pmod

Description

Syntax:

BIGINT PMOD(BIGINT x, BIGINT y) DOUBLE PMOD(DOUBLE x, DOUBLE y)

This function returns the minimum positive result of x mod y in the residue systems. Specifically, it returns (x%y+y)%y.

Example

MySQL [test]> SELECT PMOD(13,5);
+-------------+
| pmod(13, 5) |
+-------------+
| 3 |
+-------------+

MySQL [test]> SELECT PMOD(-13,5);
+-------------+
| pmod(-13, 5) |
+-------------+
| 2 |
+-------------+

Keywords

PMOD